package com.zhongfl.crm.lixiao.mapper;

import com.zhongfl.crm.enums.boss.WorkOrderStatus;
import com.zhongfl.crm.enums.boss.WorkOrderTypeCode;
import com.zhongfl.crm.model.boss.WorkOrder;
import com.zhongfl.crm.model.boss.WorkOrderQuery;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * tb_work_order
 * Created by wangkun23 on 2018/1/17.
 */
public interface WorkOrderMapper {
    int deleteByPrimaryKey(Integer id);

    int insertSelective(WorkOrder record);

    WorkOrder selectByPrimaryKey(Integer id);

    WorkOrder selectByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") WorkOrderTypeCode type);

    int updateByWorkOrderNo(WorkOrder record);

    /**
     * 查询列表
     *
     * @return
     */
    List<WorkOrder> findList(WorkOrderQuery workOrderQuery);

    List<WorkOrder> findReceiveList(WorkOrderQuery workOrderQuery);


    /**
     * 根据工单号查询
     */
    WorkOrder findByWorkOrderNo(@Param("workOrderNo") String workOrderNo);


    /**
     * 根据类型和状态查询
     */
    List<WorkOrder> findByCodeAndStatus(@Param("orderNo") String orderNo,
                                        @Param("workOrderTypeCode") WorkOrderTypeCode workOrderTypeCode,
                                        @Param("status") WorkOrderStatus status);

    /**
     * 条件查询
     *
     * @param workOrderQuery
     * @return
     */
    List<WorkOrder> findListByWorkOrderQuery(WorkOrderQuery workOrderQuery);


    List<WorkOrder> selectByWorkOrderTypeCode(WorkOrderTypeCode typeCode);

    /**
     * 通过工单号查询
     * @param workOrderNo 工单号
     * @return 工单信息
     */
    WorkOrder selectByWorkOrderNo(String workOrderNo);

    /**
     * 根据工单类型,订单号,工单状态查询
     *
     * @param workOrderTypeCode
     * @param orderNo
     * @param workOrderStatus
     * @return
     */
    WorkOrder selectByWorkOrderTypeCodeAndOrderNo(@Param("workOrderTypeCode") WorkOrderTypeCode workOrderTypeCode, @Param("orderNo") String orderNo, @Param("workOrderStatus") WorkOrderStatus workOrderStatus);

    List<WorkOrder> selectByOrderNo(@Param("orderNo") String orderNo);

    List<WorkOrder> findWorkOrderList(WorkOrderQuery workOrderQuery);

    List<WorkOrder> selectByOrderNoAndWorkOrderTypeCode(@Param("workOrderTypeCode") WorkOrderTypeCode workOrderTypeCode, @Param("orderNo") String orderNo);

    /**
     * 根据条件查询未评分工单信息
     * @param workOrderQuery 查询条件
     */
    List<WorkOrder> findUnGradeList(WorkOrderQuery workOrderQuery);

    void updateEndTimeByWorkOrderNo(@Param("workOrderNo") String workOrderNo, @Param("endTime") Date endTime);

    /**
     * 根据订单号删除所有工单
     * @param orderNo
     * @return
     */
    int deleteByOrderNo(String orderNo);
}